import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import static java.lang.Thread.sleep;

/**
 * @Author：徐志荣
 * @Date：2023/5/22 11:33
 */
//针对alert的操作
public class Test8 {
    public static void main(String[] args) throws InterruptedException {
        WebDriver webDriver = new ChromeDriver();
        webDriver.get("http://localhost:63342/_20230512_TestCode/src/main/html/test04.html?_ijt=3bj6vvhipmrki55pdeojulomp8&_ij_reload=RELOAD_ON_SAVE");
        webDriver.findElement(By.cssSelector("button")).click();
        sleep(3000);
        //alert弹窗取消
        webDriver.switchTo().alert().dismiss();
        sleep(3000);
        //点击按钮
        webDriver.findElement(By.cssSelector("button")).click();

        //在alert弹窗中输入沙天琦
        webDriver.switchTo().alert().sendKeys("咕咕咕");
        //alert弹窗确定
        sleep(3000);
        webDriver.switchTo().alert().accept();
    }
}
